package com.docc.docc;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.Date;

/**
 * Created by Administrator on 2017/9/17.
 */

public class CalendarDayText extends LinearLayout {
    public boolean isToday = false;
    public boolean isMonth = false;
    private Paint paint = new Paint();
    public TextView dateText ;
    public TextView dateText2 ;
    public Date date = new Date();
    public String lunDate = null;
    public LinearLayout linearLayout;

    public CalendarDayText(Context context) {
        super(context);
    }

    public CalendarDayText(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initControl(context);
    }

    public CalendarDayText(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initControl(context);
    }

    public void initControl(Context context){
        LayoutInflater.from(context).inflate(R.layout.calendar_day_text, this, true);
        dateText = findViewById(R.id.day_now);
        dateText2 = findViewById(R.id.day_lun);
        linearLayout = findViewById(R.id.day_line);
//        paint.setStyle(Paint.Style.STROKE);
//        paint.setColor(Color.parseColor("#ff0000"));
//        date = (TextView) findViewById(R.id.txt_calendar_day);
    }

    public void initEvent(){
        dateText.setText(String.valueOf(date.getDate()));
        if(isToday)
        {
            dateText.setTextColor(Color.parseColor("#ffffff"));
            dateText2.setTextColor(Color.parseColor("#ffffff"));
            linearLayout.setBackgroundResource(R.drawable.day_text);
        }
        if(!isMonth)
        {
            dateText.setTextColor(Color.parseColor("#c1c1c1"));
        }
        dateText2.setText(lunDate);
    }
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
//        if(isToday)
//        {
//            canvas.translate(getWidth()/2, getHeight()/2);
//            canvas.drawCircle(0, 0, getWidth()/2, paint);
//        }
    }
}
